<template xmlns="http://www.w3.org/1999/html">
  <sea-dialog ref="dialog">
    <el-tabs>
      <el-tab-pane label="运行参数">
        <variable-log-list ref="variable_log" :guid="row_id"></variable-log-list>
      </el-tab-pane>
      <el-tab-pane label="通道日志">
        <channel-log-list ref="channel_log" :guid="row_id"></channel-log-list>
      </el-tab-pane>
      <el-tab-pane label="通道日志 (脚本依赖)">
        <channel-log-tree ref="channel_log_tree" :guid="row_id"></channel-log-tree>
      </el-tab-pane>
      <el-tab-pane label="日志明细">
        <entry-log-list ref="entry_log" :guid="row_id"></entry-log-list>
      </el-tab-pane>
      <el-tab-pane label="日志详情">
        <sea-code :text="text"></sea-code>
      </el-tab-pane>
    </el-tabs>
  </sea-dialog>
</template>

<script>
import VariableLogList from "./variable_log_list";
import ChannelLogTree from "./channel_log_list";
import ChannelLogList from "./channel_log_tree";
import EntryLogList from "./entry_log_list";

/**
 * 一次性展开所有日志的面板
 */
export default {
    components: {VariableLogList, ChannelLogTree, ChannelLogList, EntryLogList}
    , props: {
        // 成功回调，通常是刷新数据表格
        onSucceed: {type: Function, default: undefined}
    }
    , data() {
        return {
            // 操作名称
            operation: undefined
            // 行级数据
            , row_data: undefined
            // 行级数据
            , row_id: undefined
            // 代码
            , text: undefined
        }
    }
    , methods: {
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            this.operation = evt;
            let jobId = row.idJob;
            let dialog = {title: 'Kettle日志', fullscreen: true};

            this.$layers.ajax({
                url: '/kettle/job/log/info'
                , method: 'GET'
                , params: {id: jobId}
            }).then((ret) => {
                if (ret.code === 0) {
                    this.text = ret.data.logField;
                }
            });

            this.$refs.dialog.open(dialog).then(() => {
                this.row_id = jobId;
            });
        }
    }
    //end
}
</script>
